﻿using Microsoft.SharePoint;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Uportal.Shp.Core.Common;
using Uportal.Shp.Core.Services;

namespace Uportal.Shp.UI.TestWP
{
    public partial class TestWPUserControl : UserControl
    {
        NLogLogger _logger = new NLogLogger(@"c:\Temp\Logs\Uportal.TestWP_${shortdate}.log");

        protected void Page_Load(object sender, EventArgs e)
        {
        }


        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            FillDropDown();

        }

        private void FillDropDown()
        {

            ddlUser.Items.Clear();
            if (ddlUser != null)
            {
                SPGroup group = SPContext.Current.Web.Groups[Settings.Get().ModeratorGroup];
                foreach (SPUser user in group.Users)
                {
                    ddlUser.Items.Add(new ListItem(user.LoginName, user.ID.ToString()));
                   
                }
                foreach(ListItem li in ddlUser.Items)
                {
                    _logger.Info(li.Value + " " + li.Text);
                }
                ddlUser.SelectedValue = "13";
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            _logger.Info("selected:" + ddlUser.SelectedItem.Value + " " + ddlUser.SelectedItem.Text + " " + ddlUser.SelectedIndex.ToString());
        }
    }
}
